package chatAI

import (
	"context"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListSessionLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewListSessionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSessionLogic {
	return &ListSessionLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ListSessionLogic) ListSession(req *types.ListSessionReq) (resp *types.Response, err error) {
	session, err := l.svcCtx.UserRpc.ListSession(l.ctx, &userclient.ListSessionRequest{})
	if err != nil {
		return &types.Response{Code: 400, Message: err.Error()}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "获取会话列表成功",
		Data:    session,
	}, nil
}
